namespace Microsoft.ServiceModel.Samples.Discovery
{
    using System;
    using System.Xml;
    using System.Xml.Serialization;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using Microsoft.ServiceModel.Samples.Discovery.Protocol;
    
    [XmlRoot(ElementName = ProtocolStrings.XAddrsElement,
        Namespace = ProtocolStrings.Namespace)]
    public class TransportAddressCollection : Collection<Uri>, IXmlSerializable
    {
        #region IXmlSerializable Members

        public System.Xml.Schema.XmlSchema GetSchema()
        {
            return null;
        }

        public void ReadXml(XmlReader reader)
        {
            // read list of Uris
            List<Uri> addrs = 
                SerializationUtility.ReadContentAsListOfUris(reader);

            // read end element
            reader.ReadEndElement();

            // update current values
            this.Clear();
            foreach (Uri addr in addrs)
                this.Add(addr);
        }

        public void WriteXml(XmlWriter writer)
        {
            SerializationUtility.WriteListOfUris(writer, this);
        }

        #endregion
    }
}
